package com.sls.web.manager.action.game;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;

import com.sls.web.manager.action.SuperAction;
import com.sls.web.manager.common.Constants;
import com.sls.web.manager.common.FilterStringSpaces;
import com.sls.web.manager.execption.ManagerException;
import com.sls.web.manager.game.pojo.OrderLogInfo;
import com.sls.web.manager.game.querybean.OrderLogInfoQuery;
import com.sls.web.manager.game.service.OrderLogInfoService;
import com.sls.web.manager.page.Pagination;

/**
 * 订单日志管理: 列表显示，详情
 * 
 * @author gesx
 * 
 */
public class OrderLogInfoAction extends SuperAction {

	private static final long serialVersionUID = 1L;
	@Resource(name = "orderLogInfoService")
	private OrderLogInfoService orderLogInfoService;
	private OrderLogInfoQuery orderLogInfoQuery;
	private Pagination<?> page;
	private String Id;
	private OrderLogInfo orderLogInfo;

	/**
	 * 列表显示
	 * 
	 * @return
	 * @throws Exception
	 */
	public String list() throws Exception {
		if (orderLogInfoQuery == null) {
			orderLogInfoQuery = new OrderLogInfoQuery();
			orderLogInfoQuery.setPageSize(Constants.INIT_PAGESIZE);
			orderLogInfoQuery.setCurrentPage(Constants.INIT_CURRENTPAGE);
		}
		try {
			String orderId = orderLogInfoQuery.getOrderId();
			orderId = FilterStringSpaces.checkStringHasSpace(orderId);
			orderLogInfoQuery.setOrderId(orderId);
			page = orderLogInfoService.queryList(orderLogInfoQuery,
					getCurrentOperator());
		} catch (ManagerException e) {
			addActionError(e.getMessage());
		}
		return LIST;
	}

	/**
	 * 详情显示s
	 * 
	 * @return
	 * @throws Exception
	 */
	public String detail() throws Exception {
		try {
			orderLogInfo = orderLogInfoService.queryById(Id,
					getCurrentOperator());
			String areaServer = orderLogInfo.getAreaServer();
			String area = "";
			String server = "";
			String areaServerStr = "";
			StringBuilder strBui = new StringBuilder();
			String[] areaServerArr = null;
			if (StringUtils.isNotEmpty(areaServer)) {
				areaServerArr = areaServer.split("##");
				if (areaServerArr.length > 0) {
					area = areaServerArr[0];
				}
				if (areaServerArr.length > 1) {
					server = areaServerArr[1];
				}
			}
			if (area != null && !("".equals(area)) && !("null".equals(area))) {
				strBui.append(area);
			}
			if (server != null && !("".equals(server))
					&& !("null".equals(server))) {
				strBui.append(";");// 区域服务器用逗号分隔
				strBui.append(server);
			}
			areaServerStr = strBui.toString().trim();
			orderLogInfo.setAreaServer(areaServerStr);
		} catch (ManagerException e) {
			addActionError(e.getMessage());
		}
		return "detail";
	}

	public Pagination<?> getPage() {
		return page;
	}

	public void setPage(Pagination<?> page) {
		this.page = page;
	}

	public String getId() {
		return Id;
	}

	public void setId(String id) {
		Id = id;
	}

	public OrderLogInfo getOrderLogInfo() {
		return orderLogInfo;
	}

	public void setOrderLogInfo(OrderLogInfo orderLogInfo) {
		this.orderLogInfo = orderLogInfo;
	}

	public OrderLogInfoService getOrderLogInfoService() {
		return orderLogInfoService;
	}

	public void setOrderLogInfoService(OrderLogInfoService orderLogInfoService) {
		this.orderLogInfoService = orderLogInfoService;
	}

	public OrderLogInfoQuery getOrderLogInfoQuery() {
		return orderLogInfoQuery;
	}

	public void setOrderLogInfoQuery(OrderLogInfoQuery orderLogInfoQuery) {
		this.orderLogInfoQuery = orderLogInfoQuery;
	}

}
